package com.zpark.service.impl;

import com.zpark.mapper.IRankingMapper;
import com.zpark.pojo.Ranking;
import com.zpark.service.IRankingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @PackageName: com.zpark.service.impl
 * @ClassName: RankingServiceImpl
 * @Description:
 * @author: RZS
 * @date: 2022/10/11  10:37
 */
@Service
public class RankingServiceImpl implements IRankingService {

    @Autowired
    private IRankingMapper rankingMapper;

    @Override
    public List<Ranking> findAll() {
        return rankingMapper.selectAll();
    }

    @Override
    public Ranking findById(Integer id) {
        return rankingMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Ranking> findByOther(Ranking ranking) {
        return rankingMapper.select(ranking);
    }

    @Override
    public Integer remove(Integer id) {
        // 创建实体类
        Ranking ranking = new Ranking();
        ranking.setId(id);

        return rankingMapper.delete(ranking);
    }

    @Override
    public Integer change(Ranking ranking) {
        return rankingMapper.updateByPrimaryKey(ranking);
    }

    @Override
    public Integer add(Ranking ranking) {
        return rankingMapper.insert(ranking);
    }

    @Override
    public List<Ranking> findPage(Integer startPage, Integer size) {
        return rankingMapper.selectPage((startPage - 1) * size, size);
    }
}
